package com.lad.transactional_propagation.controller;

import com.lad.transactional_propagation.service.PropagationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luheng
 * @create 2020-08-10 23:11
 */
@RestController
public class PropagationController {

    @Autowired
    private PropagationService propagationService;

    @GetMapping("/insertUser")
    public String insert(){
        propagationService.insertUser3();
        return "ok";
    }


   /* @Autowired
    private UserMapper userMapper;

    @GetMapping("/insertUser1")
    @Transactional(propagation = Propagation.REQUIRED)
    public void insertUser1() {
        User user = new User(1, "zs", "123", "zhangsan");
        userMapper.insertUser(user);
        insertUser2();
    }

    @Transactional(propagation = Propagation.REQUIRED)
    public void insertUser2() {
        User user = new User(2, "zs2", "123", "zhangsan2");
        userMapper.insertUser(user);
        int i = 1 / 0;
    }*/
}
